<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
	<%@ taglib prefix="sf" uri="http://www.sf-express.com/tags" %>
	<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
	<script type="text/javascript">
	 $(document).ready(function() { 
		 
		 $("#form").validator({},{
				callback:function(results){
					$("#form").ajaxSubmit(function(data) {
						 art.dialog.list['add'].close();
			        	 myDialog =  art.dialog({icon: data.success,content: data.message,lock:true});
			        	 $("#gridTable").trigger("reloadGrid", [{page:1}]); 
			         }); 
				}
			});
		 
     }); 
	 
	 $('#empNo').blur(function(){
			var empNo = $('#empNo').val();
			if(empNo == null || empNo == ''){
				art.dialog({
					icon : 'error',
					content : '请输入一个工号',
					lock : true
				});
				return;
			}
			var param = {empNo:empNo};	
			param['rand'] = Math.random();
			jQuery.ajax({
				type:'post',
				url : '<%=request.getContextPath()%>/user_org/check',
				data : param,
				success : function(data) {
					if (data.code == "warn") {
						$('#empName').val('');
						$('#orgName').val('');
						$('#orgId').val('');
						art.dialog({
							icon : data.success, 
							content : data.message,
							lock : true
						});
					} else if(data.code == "error"){
						art.dialog({
							icon : data.success,
							content : data.message,
							lock : true
						});
					}else {
						$('#empName').val(
								data.data.empName);
						$('#orgName').val(
								data.data.orgName);
						$('#empNo').val(
								data.data.empNo);
						$('#orgId').val(
								data.data.orgId);
					}
				}
			});
		});
        
	 
  $('#select_org, #orgList').click(function(){
			showDialog('user_org/organization', {
				width : '600px',
				title : '个人配置操作机构',
				lock : true,
				param : {
					orgListId : $("#operOrgIds").val(),
					orgList : $("#orgList").val()	
					}
			});
		});
		function showDialog(url, options) {
			myDialog = art.dialog(options);// 初始化一个带有loading图标的空对话框
			$.post(url, options.param, function(data) {
				myDialog.content(data);
			});
		}


	</script> 
			<form  method="post" id="form" action="user_org/add"> 
			<sf:token id="add_user_org"/>
			    <input name="operOrgIds" id="operOrgIds" type="hidden" />
			    <input name="orgId" id="orgId" type="hidden" value=""/>
				<ul class="all_list">
				    <li>
						<span class="all_title">工号：</span> 
						<span><input type="text" id="empNo" name="empNo" class="ui_input" validator='{"label":"工号","maxLength":60}' /></span>
					</li>
					<li>
						<span class="all_title">姓名：</span> 
						<span><input type="text" id="empName" name="empName" class="ui_input" readonly="readonly" validator='{"label":"姓名","maxLength":60}' /></span>
					</li>
					<li>
						<span class="all_title">所属机构：</span> 
						<span>
						     <input type="text" id="orgName" name="orgName" class="ui_input" readonly="readonly" validator='{"label":"所属机构","maxLength":60}' />
						</span>
					</li>
					<li>
						<span class="all_title">操作机构：</span> 
						<span>
						<textarea rows="10" cols="50" class="ui_input" id="orgList" validator='{"label":"操作机构","isOnBlurEnable":false}'  name="orgList"  style="width:100px;height:100px"  readonly="readonly"></textarea>
						<!-- <input class="ui_input" id="orgList" validator='{"label":"操作机构","isOnBlurEnable":false}'  name="orgList"  style="width:100px;height:100px" readonly="readonly"> -->
						<span class="all_title"><input type="button" value="选择" id="select_org" class="btn_blue m-r15"></span>
						</span>
					</li>
					<li>
							<span class="all_title"></span>
							<span><shiro:hasPermission name="operator:add"><input type="button" id="addButton" class="submit_btn submitBtn"  name="addButton"  value="提 交"></shiro:hasPermission></span>
					</li>
				</ul>
			</form>
